﻿using System;
using BP.DA;
using BP.Web;
using BP.En;
using BP.Sys;
using System.IO;

namespace BP.Demo
{
    /// <summary>
    /// 交易 属性
    /// </summary>
    public class TradeAttr : EntityNoNameAttr
    {
        /// <summary>
        /// 交易内容
        /// </summary>
        public const string Docs = "Docs";
    }
    /// <summary>
    /// 交易
    /// </summary>
    public class Trade : EntityNoName
    {

        #region 构造方法
        /// <summary>
        /// 权限控制
        /// </summary>
        public override UAC HisUAC
        {
            get
            {
                UAC uac = new UAC();
                uac.IsUpdate = true;
                uac.IsInsert = true;
                return uac;
            }
        }
        /// <summary>
        /// 交易
        /// </summary>
        public Trade()
        {
        }
        public Trade(string no)
        {
            SetValByKey(EntityNoNameAttr.No, no);
            Retrieve();
        }
        /// <summary>
        /// 重写基类方法
        /// </summary>
        public override Map EnMap
        {
            get
            {
                if (_enMap != null)
                    return _enMap;

                Map map = new Map("Demo_Trade", "交易");

                //采集数据：原始数据. 
                map.AddTBStringPK("No", null, "编号", false, true, 1, 59, 59); //000688_2023-09-09
                map.AddTBString("Name", null, "日期", true, false, 0, 100, 10, true); //日期:2025-09-09
                map.AddTBString("StockNo", null, "StockNo", true, true, 1, 59, 50);
                map.AddTBMoney("OpenNum", 0, "开盘价", true, true);
                map.AddTBMoney("MaxNum", 0, "最高", true, true);
                map.AddTBMoney("MinNum", 0, "最低", true, true);
                map.AddTBMoney("SwingNum", 0, "振幅", true, true);
                map.AddTBMoney("CloseNum", 0, "收盘价", true, true);

                _enMap = map;
                return _enMap;
            }
        }
        #endregion

        #region 基本属性
        /// <summary>
        /// 最高值
        /// </summary>
        public decimal MaxNum
        {
            get
            {
                return GetValDecimalByKey("MaxNum");
            }
            set
            {
                SetValByKey("MaxNum", value);
            }
        }
        /// <summary>
        /// 最低值
        /// </summary>
        public decimal MinNum
        {
            get
            {
                return GetValDecimalByKey("MinNum");
            }
            set
            {
                SetValByKey("MinNum", value);
            }
        }
        /// <summary>
        /// 开盘价
        /// </summary>
        public decimal OpenNum
        {
            get
            {
                return GetValDecimalByKey("OpenNum");
            }
            set
            {
                SetValByKey("OpenNum", value);
            }
        }
        public decimal CloseNum
        {
            get
            {
                return GetValDecimalByKey("CloseNum");
            }
            set
            {
                SetValByKey("CloseNum", value);
            }
        }
        public decimal SwingNum
        {
            get
            {
                return GetValDecimalByKey("SwingNum");
            }
            set
            {
                SetValByKey("SwingNum", value);
            }
        }
        public decimal SwingRate
        {
            get
            {
                return GetValDecimalByKey("SwingRate");
            }
            set
            {
                SetValByKey("SwingRate", value);
            }
        }
        public decimal StockCloseNum
        {
            get
            {
                return GetValDecimalByKey("StockCloseNum");
            }
            set
            {
                SetValByKey("StockCloseNum", value);
            }
        }
        public decimal StockMax
        {
            get
            {
                return GetValDecimalByKey("StockMax");
            }
            set
            {
                SetValByKey("StockMax", value);
            }
        }
        public decimal StockMin
        {
            get
            {
                return GetValDecimalByKey("StockMin");
            }
            set
            {
                SetValByKey("StockMin", value);
            }
        }

        public decimal StockSwing
        {
            get
            {
                return GetValDecimalByKey("StockSwing");
            }
            set
            {
                SetValByKey("StockSwing", value);
            }
        }

        public decimal StockSafeTop
        {
            get
            {
                return GetValDecimalByKey("StockSafeTop");
            }
            set
            {
                SetValByKey("StockSafeTop", value);
            }
        }
        public decimal StockSafeDown
        {
            get
            {
                return GetValDecimalByKey("StockSafeDown");
            }
            set
            {
                SetValByKey("StockSafeDown", value);
            }
        }
        public string StockNo
        {
            get
            {
                return GetValStringByKey("StockNo");
            }
            set
            {
                SetValByKey("StockNo", value);
            }
        }

        public string StockBy
        {
            get
            {
                return GetValStringByKey("StockBy");
            }
            set
            {
                SetValByKey("StockBy", value);
            }
        }
        public bool IsTop
        {
            get
            {
                return GetValBooleanByKey("IsTop");
            }
            set
            {
                SetValByKey("IsTop", value);
            }
        }
        public bool IsDown
        {
            get
            {
                return GetValBooleanByKey("IsDown");
            }
            set
            {
                SetValByKey("IsDown", value);
            }
        }
        public decimal StockCenter
        {
            get
            {
                return GetValDecimalByKey("StockCenter");
            }
            set
            {
                SetValByKey("StockCenter", value);
            }
        }



        public decimal ResultMax
        {
            get
            {
                return GetValDecimalByKey("ResultMax");
            }
            set
            {
                SetValByKey("ResultMax", value);
            }
        }
        public decimal ResultMin
        {
            get
            {
                return GetValDecimalByKey("ResultMin");
            }
            set
            {
                SetValByKey("ResultMin", value);
            }
        }
        public decimal ResultWin
        {
            get
            {
                return GetValDecimalByKey("ResultWin");
            }
            set
            {
                SetValByKey("ResultWin", value);
            }
        }
        public decimal ResultCloseNum
        {
            get
            {
                return GetValDecimalByKey("ResultCloseNum");
            }
            set
            {
                SetValByKey("ResultCloseNum", value);
            }
        }
        #endregion
    }
    /// <summary>
    /// 交易 s
    /// </summary>
    public class Trades : EntitiesNoName
    {

        #region 构造函数.
        /// <summary>
        /// 交易
        /// </summary>
        public Trades() { }
        /// <summary>
        /// 得到它的 Entity 
        /// </summary>
        public override Entity GetNewEntity
        {
            get
            {
                return new Trade();
            }
        }
        #endregion 构造函数.


        #region 为了适应自动翻译成java的需要,把实体转换成List.
        /// <summary>
        /// 转化成 java list,C#不能调用.
        /// </summary>
        /// <returns>List</returns>
        public System.Collections.Generic.IList<Trade> ToJavaList()
        {
            return (System.Collections.Generic.IList<Trade>)this;
        }
        /// <summary>
        /// 转化成list
        /// </summary>
        /// <returns>List</returns>
        public System.Collections.Generic.List<Trade> Tolist()
        {
            System.Collections.Generic.List<Trade> list = new System.Collections.Generic.List<Trade>();
            for (int i = 0; i < Count; i++)
            {
                list.Add((Trade)this[i]);
            }
            return list;
        }
        #endregion 为了适应自动翻译成java的需要,把实体转换成List.
    }
}
